package net.funtip.ormgenerator.model;

public class Association {
	
	public enum AssociationType {oneToMany, oneToOne, manyToOne}
	
	private Attribute attribute;
	private Entity referencedEntity;
	private AssociationType type;
	
	public Association(Attribute attribute, Entity referencedEntity, AssociationType type) {
		super();
		this.attribute = attribute;
		this.referencedEntity = referencedEntity;
		this.type = type;
		attribute.setAssociated(true);
		attribute.setAssociation(this);
	}

	public Attribute getAttribute() {
		return attribute;
	}
	
	public void setAttribute(Attribute attribute) {
		this.attribute = attribute;
	}
	
	public Entity getReferencedEntity() {
		return referencedEntity;
	}
	
	public void setReferencedEntity(Entity referencedEntity) {
		this.referencedEntity = referencedEntity;
	}
	
	public AssociationType getType() {
		return type;
	}
	
	public void setType(AssociationType type) {
		this.type = type;
	}
	
	public boolean isOneToOne() {
		return AssociationType.oneToOne.equals(type);
	}

	public boolean isOneToMany() {
		return AssociationType.oneToMany.equals(type);
	}

	public boolean isManyToOne() {
		return AssociationType.manyToOne.equals(type);
	}

}
